package com.neutech.maplestory.client;

import com.neutech.maplestory.entity.Hero;
import com.neutech.maplestory.util.MapleStoryFrame;

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/** （3）
 * 游戏的主入口文件
 * @author ZZQ
 * @PackageName: com.neutech.maplestory.client
 * @ClassName: MapleStoryClient
 * @Description:
 * @date 2021/1/27 13:13
 */
public class MapleStoryClient extends MapleStoryFrame {
    public Hero hero = new Hero(300,500);

    @Override
    public void init() {
        super.init();
        //添加键盘监听器
        this.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                hero.KeyPressed(e);
//                System.out.println("按下");

//                switch (e.getKeyCode()){
//                    case KeyEvent.VK_A:
//                        hero.x -= hero.speed;
//                        break;
//                    case KeyEvent.VK_W:
//                        hero.y -= hero.speed;
//                        break;
//                    case KeyEvent.VK_D:
//                        hero.x += hero.speed;
//                        break;
//                    case KeyEvent.VK_S:
//                        hero.y += hero.speed;
//                        break;
//                    default:
//                        break;
//                }

//                if(e.getKeyCode() == KeyEvent.VK_A ){
//                    System.out.println("按下");
//                }
            }

            @Override
            public void keyReleased(KeyEvent e) {
                hero.keyReleased(e);
//                System.out.println("抬起");
//                if(e.getKeyCode() == KeyEvent.VK_S){
//                    System.out.println("抬起");
//                }

//                switch (e.getKeyCode()){
//                    case KeyEvent.VK_A:
//                        break;
//                    case KeyEvent.VK_W:
//                        break;
//                    case KeyEvent.VK_D:
//                        break;
//                    case KeyEvent.VK_S:
//                        break;
//                    default:
//                        break;
//                }
            }
        });
    }

    @Override
    public void paint(Graphics g) {
        hero.draw(g);
        Font f = g.getFont();
        g.setFont(new Font("微软雅黑",Font.BOLD,30));
        g.drawString("人物的方向为：" + hero.dir,100,100);
        g.drawString("人物的动作为：" + hero.action,100,150);
        g.drawString("人物趴下" + hero.down,100,200);
        g.setFont(f);
    }

    public static void main(String[]args){
        new MapleStoryClient().init();
    }
}


